package com.qfedu.provider.controller;

import com.qfedu.params.FansAdd;
import com.qfedu.provider.service.DbFunsService;
import com.qfedu.utils.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * @date 2024/11/23 下午12:04
 */
@RestController
@RequestMapping("/server/fan")
@Tag(name = "粉丝/关注管理")
@RequiredArgsConstructor
public class FanController {

    private final DbFunsService dbFunsService;

    /**
     * 查询粉丝/关注我的人
     * @param userId 根据用户id查询关注我的人
     * @return 结果集
     */
    @Operation(summary = "根据用户id查询粉丝/关注我的人")
    @GetMapping("findByUserId")
    public R findAll(Integer userId) {
        return dbFunsService.findByUserId(userId);
    }

    /**
     * 关注博主业务
     * @param fansAdd 关注博主
     * @return 结果集
     */
    @Operation(summary = "添加粉丝/关注")
    @PostMapping("add")
    public R add(@RequestBody FansAdd fansAdd) {

        return dbFunsService.saveFans(fansAdd);
    }

    /**
     * 取关业务
     * @param fansAdd 关注博主参数
     * @return 结果
     */
    @Operation(summary = "取消粉丝/关注")
    @PostMapping ("delete")
    public R delete(@RequestBody FansAdd fansAdd) {
        return dbFunsService.lgDelFans(fansAdd);
    }
}
